package com.base.caselib.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.base.caselib.R;

/**
 * Created by weikailiang on 2019/10/12.
 */

public class EditNumCustom extends FrameLayout{
    private TextView mTvName;
    private EditText mEtText;
    private String mRowIndex;
    public EditNumCustom(@NonNull Context context) {
        super(context);
        init(null);
    }

    public EditNumCustom(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(attrs);
    }

    public EditNumCustom(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(attrs);
    }

    public void init(AttributeSet attrs){
        LayoutInflater.from(getContext()).inflate(R.layout.item_edtextnum, this);
        mTvName = findViewById(R.id.tv_name);
        mEtText = findViewById(R.id.tv_edit);

    }
    public void setmTvName(String name){
        if (mTvName != null){
            mTvName.setText(name);
        }
    }
    public void setmEtText(String etText){
        if (mEtText != null){
            mEtText.setText(etText);
        }
    }
    public void setmEtTextHint(String etText){
        if (mEtText != null){
            mEtText.setHint(etText);
        }
    }
    public String getmEtText(){
        if (mEtText != null){
            return mEtText.getText().toString();
        }else {
            return "";
        }
    }
    public void setReadLine(boolean isRead){
        if (mEtText!=null){
            if (isRead){
                mEtText.setEnabled(false);
            }
        }
    }

    public String getmRowIndex() {
        return mRowIndex;
    }

    public void setmRowIndex(String mRowIndex) {
        this.mRowIndex = mRowIndex;
    }
}
